snapshot: Add gtk_snapshot_from_parent
authorTimm Bäder <tbaeder@redhat.com>
Wed, 16 Jan 2019 07:30:42 +0000 (08:30 +0100)
committerTimm Bäder <mail@baedert.org>
Wed, 16 Jan 2019 18:01:40 +0000 (19:01 +0100)
commitcf1526cca62a956d1605fa6cdcc241e59c039600
treee2c95587761dbc7d734d8a3585f58476c637664e
parentc1c764255f5108ea7b16ac590cc492a748d6fb26
snapshot: Add gtk_snapshot_from_parent

Most of the time, the GtkSnapshot objects we create while snapshotting
widgets don't end up containing all that many nodes or states in their
respective node or state stack. This undermines the amortized allocation
behavior of the G(Ptr)Array we use for the stacks. So instead, use the
(until now unused) parent_snapshot GtkSnapshot* passed to
gtk_widget_create_render_node and reuse its node and state stack.

We do not avoid allocating a new GtkSnapshot object, but we do avoid
allocating a ton of G(Ptr)Array objects and we also avoid realloc'ing
their storage.
gtk/gtksnapshot.c
gtk/gtksnapshotprivate.h
gtk/gtkwidget.c